const constant = require('../constants/constant.js');

const sendRequest = (url, method, data, header) => {
	var promise = new Promise((resolve, reject) => {
		wx.request({
			url: constant.BACKEND_DOMAIN + url + '?city=' + data,
			method: method,
			header: header,
			success: function (res) {
				resolve( res.data );
			},
			error: function (e) {
				reject( e );
			}
		})
	});
	return promise;
}

const get = (url, data) => {
	return sendRequest(url, 'GET', data);
}

module.exports = {
	sendRequest: sendRequest,
	get : get,
}
